package com.nineclock.document.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.document.DocumentControllerApi;
import com.nineclock.document.dto.DocFileDto;
import com.nineclock.document.dto.DocFolderDto;
import com.nineclock.document.service.DocFileHitoryService;
import com.nineclock.document.service.DocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: nineclock-group-02
 * @description: ${文档中心}
 * @author: TimLi
 * @create: 2021-07-22 11:00
 **/
@RestController
@RequestMapping
public class DocumentController implements DocumentControllerApi {

    //注入service
    @Autowired
    DocumentService documentService;

    @Autowired
    DocFileHitoryService docFileHitoryService;

    @Override
    @PostMapping("/insertFile")
    public Result createDoc(@RequestBody DocFileDto docFileDto){

        //调用service层
        documentService.createDoc(docFileDto);
        docFileHitoryService.createFileHistory(docFileDto);
        return Result.success();
    }

    @Override
    @PostMapping("/insertFolder")
    public Result createFolder(@RequestBody DocFolderDto docFolderDto) {

        documentService.createFolder(docFolderDto);
        return Result.success();
    }
}
